﻿using BW.MesProject.Public.ErrorCode;
using BW.MesProject.WareHouse.Domain;
using BW.MesProject.WareHouse.Infrastructure;
using BW.MesProject.WareHouse.Infrastructure.Dto.Input;
using BW.MesProject.WareHouse.Infrastructure.Dto.OutPut;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace BW.MesProject.WareHouse.Host.Controllers
{
    /// <summary>
    /// 仓库
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WareHouseController : ControllerBase
    {
        // GET: api/<WareHouseController>
        private readonly IWareHouseServices wareHouseServices;

        public WareHouseController(IWareHouseServices wareHouseServices)
        {
            this.wareHouseServices = wareHouseServices;
        }
        /// <summary>
        /// 添加仓库
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddWareHouse(WarehouseModel model)
        {
            return wareHouseServices.AddWareHouse(model);
        }
        /// <summary>
        /// 删除仓库
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> DeleteWareHouse(long Id)
        {
            return wareHouseServices.DeleteWareHouse(Id);
        }
        /// <summary>
        /// 获取仓库
        /// </summary>
        /// <param name="qryInput">查询参数</param>
        /// <returns>仓库列表</returns>
        [HttpGet]
        public ApiResult<List<WareHouseOut>> GetWareHouse([FromQuery] QryInput qryInput)
        {
            return wareHouseServices.GetWareHouse(qryInput);
        }
        /// <summary>
        /// 修改仓库
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdateWareHouse(WarehouseModel model)
         {
            return wareHouseServices.UpdateWareHouse(model);
        }

        /// <summary>
        /// 修改启用
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateEnable(WarehouseModel model)
        {
            return wareHouseServices.UpdateEnable(model);
        }

        /// <summary>
        /// 软删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> UpdateDelete(long Id)
        {
            return wareHouseServices.UpdateDelete(Id);
        }

        /// <summary>
        /// 查询编码
        /// </summary>
        /// <param name="WareHouseID"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<int> GetWareHouseID(string WareHouseID)
        {
            return wareHouseServices.GetWareHouseID(WareHouseID);
        }
    }
}
